-- @owner: wan005
-- @date: 2024-08-12
-- @testpoint: 验证isnull()函数作为关键字使用

--prestep1:切换B库;expect:执行成功
@conn PrimaryDbBmode;
show sql_compatibility;

--step1:作为列名;expect:成功
drop table if exists isnull_test cascade;
create table isnull_test(isnull text);
insert into isnull_test values('0');

--step2:作为索引名;expect:成功
create index on isnull_test(isnull);

--step3:作为表名;expect:成功
drop table if exists isnull cascade;
create table isnull(isnull text);
drop table if exists isnull cascade;

--step4:作为数据库名;expect:成功
drop database if exists isnull;
create database isnull;
drop database isnull;

--step5:作为外部数据源名;expect:成功
drop data source if exists isnull;
create data source isnull;
drop data source isnull;

--step6:作为自定义函数名;expect:成功
create or replace function isnull(c1 int)
returns text
as  $$
begin
    return c1;
end;
$$language plpgsql;
/
drop function if exists isnull;

--step7:作为存储过程名;expect:成功
drop table if exists t_isnull_0025;
create table t_isnull_0025(c1 text);
CREATE OR REPLACE PROCEDURE isnull(P1 IN text) AS
BEGIN
insert into t_isnull_0025 values ('00001');
raise info '测试isnull作为存储过程名';
END;
/
drop procedure if exists isnull;

--step8:作为角色名;expect:成功
drop role if exists isnull;
create role isnull with password 'gauss@123' valid until '2001-12-12';
drop role isnull;

--step9:作为用户组名;expect:成功
drop group if exists isnull;
create group isnull with password 'gauss@123';
drop group isnull;

--step10:作为模式名;expect:成功
drop schema if exists isnull;
create schema isnull;
drop schema isnull;

--step11:作为序列名;expect:成功
create sequence public.isnull start 100 cache 50;
drop sequence public.isnull;

--step12:作为用户名;expect:成功
drop user if exists isnull;
CREATE USER isnull PASSWORD 'Bigdata@123';
drop user isnull;

--step13:作为游标名;expect:成功
drop table if exists isnull_test cascade;
create table isnull_test(cid int,fid int);
start transaction;
cursor isnull for select * from isnull_test order by 1;
close isnull;
end;

--step14:清理环境;expect:成功
drop table if exists isnull_test cascade;
drop table if exists t_isnull_0025;